<?php

namespace IMT\UserBundle\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
 * IMT\UserBundle\Entity\Participant
 *
 * @ORM\Table()
 * @ORM\Entity
 */
class Participant extends Person
{
    /**
     * @var integer $id
     *
     * @ORM\Column(name="id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    private $id;
    
    /**
     * @ORM\OneToOne(targetEntity="IMT\UserBundle\Entity\User", mappedBy="participant")
     * @ORM\joinColumn(name="user_id", referencedColumnName="id")
     */
    private $user;
    
    /**
     * @ORM\ManyToMany(targetEntity="IMT\UserBundle\Entity\Group")
     * @ORM\JoinTable(name="participant_group",
     *      joinColumns={@ORM\JoinColumn(name="participant_id", referencedColumnName="id")},
     *      inverseJoinColumns={@ORM\JoinColumn(name="group_id", referencedColumnName="id")}
     * )
     */
    private $groups;
    
    /**
     * @ORM\ManyToMany(targetEntity="IMT\AccountBundle\Entity\Account", mappedBy="participants")
     */
    private $accounts;
    
    /**
     * @ORM\OneToMany(targetEntity="IMT\EventBundle\Entity\ParticipantEvent", mappedBy="participant")
     */
    private $events;

    /**
     * Get id
     *
     * @return integer 
     */
    public function getId()
    {
        return $this->id;
    }
    public function __construct()
    {
        $this->user = null;
    }
    
    public function getPerson(){
    	return parent::$this;
    }
    
    public function setPerson(Person $person){
    	$this->setCivility($person->getCivility());
    	$this->setFirstname($person->getFirstname());
    	$this->setName($person->getName());
    }
    
    /**
     * Add user
     *
     * @param IMT\UserBundle\Entity\User $user
     */
    public function setUser(\IMT\UserBundle\Entity\User $user)
    {
        $this->user = $user;
    }

    /**
     * Get user
     *
     * @return IMT\UserBundle\Entity\User 
     */
    public function getUser()
    {
        return $this->user;
    }

    /**
     * Add groups
     *
     * @param IMT\UserBundle\Entity\Group $groups
     */
    public function addGroup(\IMT\UserBundle\Entity\Group $groups)
    {
        $this->groups[] = $groups;
    }

    /**
     * Get groups
     *
     * @return Doctrine\Common\Collections\Collection 
     */
    public function getGroups()
    {
        return $this->groups;
    }

    /**
     * Add accounts
     *
     * @param IMT\AccountBundle\Entity\Account $accounts
     */
    public function addAccount(\IMT\AccountBundle\Entity\Account $accounts)
    {
        $this->accounts[] = $accounts;
    }

    /**
     * Get accounts
     *
     * @return Doctrine\Common\Collections\Collection 
     */
    public function getAccounts()
    {
        return $this->accounts;
    }

    /**
     * Add events
     *
     * @param IMT\EventBundle\Entity\ParticipantEvent $events
     */
    public function addParticipantEvent(\IMT\EventBundle\Entity\ParticipantEvent $events)
    {
        $this->events[] = $events;
    }

    /**
     * Get events
     *
     * @return Doctrine\Common\Collections\Collection 
     */
    public function getEvents()
    {
        return $this->events;
    }
}